cmake_minimum_required(VERSION 3.10)
project(dokan-ebackup)

set (CMAKE_CXX_STANDARD 20)


set(ROCKSDB_BUILD_SHARED OFF)
set(WITH_TESTS OFF)
set(WITH_BENCHMARK_TOOLS OFF)
set(WITH_CORE_TOOLS OFF)
set(WITH_TOOLS OFF)
set(WITH_JNI OFF)
set(WITH_TRACE_TOOLS OFF)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/3rd/rocksdb")

set(SOURCE_ROOT "${CMAKE_CURRENT_LIST_DIR}/src")
set(DOKAN_ROOT "${CMAKE_CURRENT_LIST_DIR}/3rd/dokan")
set(SPDLOG_ROOT "${CMAKE_CURRENT_LIST_DIR}/3rd/spdlog")
set(WIN_ROOT "${CMAKE_CURRENT_LIST_DIR}/3rd/win")

set(SOURCE_FILES
	"${WIN_ROOT}/mman.c"
	"${SOURCE_ROOT}/lyj_kv_store.c"
	"${SOURCE_ROOT}/lyj_filenode.c"
	"${SOURCE_ROOT}/lyj_dokan.c"
	"${SOURCE_ROOT}/lyj_ebackup.c"
)

set(HEADER_FILES
	"${SOURCE_ROOT}/lyj_config.h"
	"${SOURCE_ROOT}/lyj_types.h"
	"${SOURCE_ROOT}/lyj_log.h"
	"${SOURCE_ROOT}/lyj_kv_store.h"
	"${SOURCE_ROOT}/lyj_filenode.h"
	"${SOURCE_ROOT}/lyj_dokan.h"
	"${SOURCE_ROOT}/lyj_ebackup.h"
)

if (NOT WIN32)
	message(FATAL_ERROR "Error: This project can only be built on Windows.")
endif ()
add_definitions(-D_UNICODE -DUNICODE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_STRUCT_TIMESPEC -D_ENABLE_ATOMIC_ALIGNMENT_FIX -DSPDLOG_WCHAR_TO_UTF8_SUPPORT)

include_directories("${DOKAN_ROOT}/include")
include_directories("${SPDLOG_ROOT}/include")
include_directories("${WIN_ROOT}")



add_executable(dokan-ebackup "${SOURCE_FILES}" "${HEADER_FILES}")
target_link_libraries(dokan-ebackup "${DOKAN_ROOT}/lib/dokan2.lib")

target_link_libraries(dokan-ebackup rocksdb)


set(KVFS_SOURCE_ROOT "${CMAKE_CURRENT_LIST_DIR}/kvfs")


set(KVFS_SOURCE_FILES
	"${KVFS_SOURCE_ROOT}/filenode.cpp"
	"${KVFS_SOURCE_ROOT}/filenodes.cpp"
	"${KVFS_SOURCE_ROOT}/main.cpp"
	"${KVFS_SOURCE_ROOT}/memfs.cpp"
	"${KVFS_SOURCE_ROOT}/memfs_helper.cpp"
	"${KVFS_SOURCE_ROOT}/memfs_operations.cpp"
)

set(KVFS_HEADER_FILES
	"${KVFS_SOURCE_ROOT}/filenode.h"
	"${KVFS_SOURCE_ROOT}/filenodes.h"
	"${KVFS_SOURCE_ROOT}/memfs.h"
	"${KVFS_SOURCE_ROOT}/memfs_helper.h"
	"${KVFS_SOURCE_ROOT}/memfs_operations.h"
)



add_executable(dokan-kvfs "${KVFS_SOURCE_FILES}" "${KVFS_HEADER_FILES}")
target_link_libraries(dokan-kvfs "${DOKAN_ROOT}/lib/dokan2.lib")

target_link_libraries(dokan-kvfs rocksdb)
